<!doctype html>
<html>
<head>
    <title>站点管理 - <?php if($info){
            echo '编辑站点-'.$info['sid'];
        }else{
            echo '添加站点';
        }?> </title>
    <?php $this->load->module('admin/index/page_header');?>
    <link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/public/Lib/webuploader/webuploader.css">
    <!--引入JS-->
    <script type="text/javascript" src="<?php echo URLPRE;?>static/public/Lib/webuploader/webuploader.js"></script>
<style>
    .numer{}
</style>
</head>
<body>
<?php






$this->load->config('template');
$templates = $this->config->config['template'];

?>
<div class="wrap">
    <div id="home_toptip"></div>
   <?php if($info){?>
       <div class="table_full">
        <div class="h_a clearfix">站点管理 <em class="red">当前站点ID: <?php echo $GLOBALS['sid']?> </em><a style="float:right" href="<?php echo site_url('admin/index/logout')?>">退出登录</a></div>
        <div class="nav">
                <ul class="cc tab" id="conf_menu">
                    <li ><a href="<?php echo site_url('admin/site/index?linshi=1');?>">临时域名站点列表</a></li>
                    <li ><a href="<?php echo site_url('admin/site/index');?>">已上线站点列表</a></li>
                    <li class="current"><a href="<?php echo site_url('admin/site/add');?>"><?php if($info){
                                echo '编辑站点';
                            }else{
                                echo '添加站点';
                            }?></a></li>
                </ul>
            </div>
            <div class="h_a"><?php if($info){
                    echo '编辑站点信息 - ' . '<em class="red">'.$info['sid'].'</em>';
                }else{
                    echo '添加站点';
                }?></div>
            <form class="formvalidate" action="" method="post">
            <div class="table_full">
                <table width="100%" class="tab_label" id="general_config">
                    <col class="th" />
                    <col/>
                    <?php if(!$info['sid']){?>
                        <tr>
                        <th>网站ID</th>
                        <td>
                            <input size="50" type="text" class="input" name="row[sid]" value="" validate="{rangelength:[1,20]}" />
                            <span class="fun_tips">旧站id，没有则不填</span>
                        </td>
                    </tr>
                    <?php }?>
                    <tr>
                        <th>网站名称</th>
                        <td>
                            <input size="50" type="text" class="input" name="row[name]" value="<?php echo $info['name']?>" validate="{rangelength:[1,20]}" />
                            <span class="fun_tips">仅供网站管理列表显示</span>
                        </td>
                    </tr>
                    <tr>
                        <th>网址</th>
                        <td><input size="50" type="text" class="input" name="row[url]" value="<?php echo $info['url'] ? $info['url'] : ''?>" />
                            <span class="fun_tips">“http://”开头，结尾不能有“/”</span>
                        </td>
                    </tr>
<!--                    <tr>-->
<!--                        <th>站长</th>-->
<!--                        <td><input size="50" type="text" class="input" name="row[master]" value="--><?php //echo $info['master']?><!--" validate="{required:true}" />-->
<!--                            <span class="fun_tips">站长姓名</span>-->
<!--                        </td>-->
<!--                    </tr>-->
<!--                    <tr>-->
<!--                        <th>站长联系方式</th>-->
<!--                        <td><input size="50" type="text" class="input" name="row[mobile]" value="--><?php //echo $info['mobile']?><!--" validate="{required:true}" />-->
<!--                            <span class="fun_tips">电话号码、手机号</span>-->
<!--                        </td>-->
<!--                    </tr>-->
                    <tr>
                        <th>站长帐号</th>
                        <td><input size="50" type="text" class="input" name="row[founder]" value="<?php echo $info['founder']?>" />
                            <span class="fun_tips">登录网站使用的帐号。<?php if($info){?>不修改请留空！<?php }?></span>
                        </td>
                    </tr>
                    <tr>
                        <th>初始密码</th>
                        <td><input size="50" type="text" class="input" name="admin[password]" value="<?php echo $info['password']?>" <?php if(!$info){echo 'validate="{rangelength:[4,16]}" ';}?>/>
                            <span class="fun_tips">登录网站使用的密码。<?php if($info){?>不修改请留空！<?php }else{?>不填默认为:123456<?php }?></span>
                        </td>
                    </tr>
                    <tr>
                        <th>站点类型</th>
                        <td>
                            <select name="row[type]" validate="{required:true}">
                                <option <?php echo $info['type'] == '分销商' ? 'selected' : '';?> value="分销商">分销商</option>
                                <option <?php echo $info['type'] == '供应商' ? 'selected' : '';?> value="供应商">供应商</option>
                                <option <?php echo $info['type'] == '供应/分销商' ? 'selected' : '';?> value="供应/分销商">供应/分销商</option>
                                <option <?php echo $info['type'] == '酒店' ? 'selected' : '';?> value="酒店">酒店</option>
                                <option <?php echo $info['type'] == '景区' ? 'selected' : '';?> value="景区">景区</option>
                                <option <?php echo $info['type'] == '微信版' ? 'selected' : '';?> value="微信版">微信版</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>模板</th>
                        <td>
                            <select name="configs[site_template]">
                            <?php
                            foreach ($templates as $k => $v) { ?>
                                <option value="<?php echo $k?>" <?php if($k==$info['template']){echo 'selected';}?>><?php echo $v['name']?></option>
                            <?php }?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>状态</th>
                        <td>
                            <label><input type="radio" <?php echo $info['status'] == '1' ? 'checked' : '';?> name="row[status]" value="1" checked />激活</label>
                            <label><input type="radio" <?php echo $info['status'] == '0' ? 'checked' : '';?> name="row[status]" value="0" />关闭</label>
                        </td>
                    </tr>

                    <tr>
                        <th>&nbsp;</th>
                        <td>
                            <input type="hidden" name="sid" value="<?php echo $info ? $info['sid'] : 0?>" />
                            <button type="submit" class="btn btn_submit J_ajax_submit_btn">提交</button>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
    </div>
    <?php }?>
<?php if(!$info){?>
<div class="table_full">
<div class="h_a clearfix">站点管理 <em class="red">当前站点ID: <?php echo $GLOBALS['sid']?> </em><a style="float:right" href="<?php echo site_url('admin/index/logout')?>">退出登录</a></div>
<div class="nav">
        <ul class="cc tab" id="conf_menu">
            <li ><a href="<?php echo site_url('admin/site/index?linshi=1');?>">临时域名站点列表</a></li>
            <li ><a href="<?php echo site_url('admin/site/index');?>">已上线站点列表</a></li>
            <li class="current"><a href="<?php echo site_url('admin/site/add');?>"><?php if($info){
                        echo '编辑站点';
                    }else{
                        echo '添加站点';
                    }?></a></li>
        </ul>
    </div>
</div>
<div class="table_list">
    <div class="h_a">批量添加</div>
<form class="formvalidate" action="" method="post">
    <table width="100%" class="tab_label" id="general_config">
        <tr>
            <td><b>站点ID</b></td>
            <td><b>模板</b></td>
            <td><b>网站名称</b></td>
            <td><b>网址（留空自动生成）</b></td>
            <td><b>登录帐号</b></td>
            <td><b>密码（留空123456）</b></td>
            <td><b>站点类型</b></td>
        </tr>
        <tr id="first">
            <td>
                <span class="numer">1</span>
                <input style="width:20px" type="text" class="input" name="rows[sid][]" value="" validate="{rangelength:[1,20]}" />
            </td>
            <td>
                <select name="rows[site_template][]">
                <?php
                foreach ($templates as $k => $v) { if(strpos($v['name'], '标准') === false){continue;} ?>
                    <option value="<?php echo $k?>"><?php echo $v['name']?></option>
                <?php }?>
                </select>
            </td>
            <td> <input type="text" class="input" name="rows[name][]" validate="{required:true,rangelength:[1,20]}" /></td>
            <td>
                <input size="50" type="text" class="input" name="rows[url][]" value="" />
            </td>
            <td>
                <input type="text" class="input founder" name="rows[founder][]" value="管理员1" validate="{required:true}" />
            </td>
            <td>
                <input type="text" class="input" name="rows[password][]" <?php if(!$info){echo 'validate="{rangelength:[4,16]}" ';}?>/>
            </td>
            <td>
                <select name="rows[type][]" validate="{required:true}">
                    <option value="分销商">分销商</option>
                    <option value="供应商">供应商</option>
                    <option value="供应/分销商">供应/分销商</option>
                    <option value="酒店">酒店</option>
                    <option value="景区">景区</option>
                    <option value="微信版">微信版</option>
                </select>
            </td>
        </tr>
        <tr id="ctrl">
        <td colspan="7">
            <input type="hidden" name="rows[status][]" value="1" />
            <input type="hidden" name="multi" value="1" />
            <button type="submit" class="btn btn_submit J_ajax_submit_btn">提交</button>
            <a class="add" onclick="return add_row(1);">增加1行</a>
            <a class="add" onclick="return add_row(4);">增加4行</a>
            <a class="add" onclick="return add_row(9);">增加9行</a>
        </td>
        </tr>
    </table>
    </form>
</div>
<?php }?>
</div>

<script type="text/javascript">
var j = 1;
function add_row(num){
    for(var i = 0;i<num;i++){
        var h = $('#first').clone();
        h.find('.numer').html(++j);
        h.insertBefore($('#ctrl'));
    }
    return false;
}
function syncfounder(obj){
    $(obj).parent().parent().find('.founder').val($(obj).val());
}
</script>
</body>
</html>